import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0dIQv9yoVwwOdkL7RGKd\n' +
  'NmM5kH57cBS1RXbREOpqP4m3/zTjzxYYP9w7+JsTMnaRGZT/nRjcr7DCZHB5XkA5\n' +
  'zd+qhuM3n8jZShvZs+QYj0y0D/SesEF1RcH1SXZPdfLQWAFDIPyomNjU7PuH+MBE\n' +
  '7JFDuFJ5ZFiElfFOpa2dwSfICd3h8jGKd5Eazyd/jxB0dmy/6Cav0gZiSDj8vrZY\n' +
  'Cqmf+hYWg4BSjLoLgOTsyike28mrUDBam3gQZQNCm5MgqFixQIIEqFdf72bGzr8H\n' +
  'JUGEZFtjtae2G/jBU0oysXywzMr1oP6yX45a22A2BvgPFDcL5h24wE6RZ+3I065+\n' +
  'MwIDAQAB'

const privateKey = 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDR0hC/3KhXDA52\n' +
  'QvtEYp02YzmQfntwFLVFdtEQ6mo/ibf/NOPPFhg/3Dv4mxMydpEZlP+dGNyvsMJk\n' +
  'cHleQDnN36qG4zefyNlKG9mz5BiPTLQP9J6wQXVFwfVJdk918tBYAUMg/KiY2NTs\n' +
  '+4f4wETskUO4UnlkWISV8U6lrZ3BJ8gJ3eHyMYp3kRrPJ3+PEHR2bL/oJq/SBmJI\n' +
  'OPy+tlgKqZ/6FhaDgFKMuguA5OzKKR7byatQMFqbeBBlA0KbkyCoWLFAggSoV1/v\n' +
  'ZsbOvwclQYRkW2O1p7Yb+MFTSjKxfLDMyvWg/rJfjlrbYDYG+A8UNwvmHbjATpFn\n' +
  '7cjTrn4zAgMBAAECggEAWsbpnDiZVF/Q+fVsxF9t6RPw2cT/HrS24IDRXuIsaaTp\n' +
  'yC5XyUaj4y0jfSGKorCNgmXmWU9iW1i8IbxPpilfWOTF4Gn5r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stsCgYB3lOsuQFsR6rU0v1toXz6+\n' +
  'UmzZt0plz/ZkKfIhcjy3YKgPwqRlCu57QMmPkFtxje9kDJMVj48ZYp6G0O7PElnz\n' +
  'EslgQ+xj/1s0ZnyO+FdiN0EKqkfssFZmMzAggz0qHqyfFpddcRrSJsskapwd+GKo\n' +
  'MzAaDAL8+2l9eTn4Nz4z4A=='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

